﻿<script>
    function GetFullDate(epochInt) {
        var date = Date.fromEpoch(epochInt);
        if (date && date != null)
            return date.toFullDate();
        return "";
    }
    function GetFullDateTime(epochInt) {
        var date = Date.fromEpoch(epochInt);
        if (date && date != null)
            return date.toFullDateTime();
        return "";
    }
    function GetNiceTime(dateTime) {
        if (!dateTime || dateTime == null) return '';
        return Date.fromEpoch(dateTime).toNiceTime();
    };
</script>
<script id="completedWorkitemDetail" type="text/x-jquery-tmpl"> 
    <form class="workitemList-formWorkItem" action="/Project/DoUpdateWorkItem" method="post"
    style="">
    <div class="workitemList-container-title">
        <input type="text" class="workitemList-Title" name="title" value="${Title}">
        <input type="hidden" class="workitemList-Id" name="id" value="${Id}"></div>
    <p class="workitemList-container-create">
        这个任务由 <span class="workitemList-CreatorName">${CreatorName}</span> 创建于 <span class="workitemList-CreateOn">
            ${Date.fromEpoch(CreateOn).toNiceTime()} 小时前</span>

            {{if IsTrace}}
            <span class="workitemList-IsTrace">
                <span class="workitemList-CreatorName">${CreatorName}</span> 
                正在追踪这个任务
            </span>
            {{/if}}     
    </p>
    <div class="workitemList-workitem" style="display: block;">
        <dl class="workitemList-dl">
            <dt class="workitemList-dd-l"><span>负责人:</span></dt>
            <dd class="workitemList-dd-r">
                {{if OwnerName}}
                    <span class="workitemList-OwnerName">${OwnerName}</span>    
                {{else}}
                    <span class="workitemList-OwnerName">&nbsp;--&nbsp;</span>    
                {{/if}}
                <input type="hidden" name="ownerId" class="workitemList-hiden-OwnerId" value="${OwnerId}" />
            </dd>
        </dl>
        <dl class="workitemList-dl">
            {{if (Status != "Completed")}}
                <dt class="workitemList-dd-l">到期:</dt>
                <dd class="workitemList-dd-r"><input type="text" class="workitemList-PlanOn" name="planOn" value="${GetFullDate(PlanOn)}"/></dd>
            {{else}}
                <dt class="workitemList-dd-l">完成时间:</dt>
                <dd class="workitemList-dd-r"><span class="workitemList-FinishOn" >${GetFullDateTime(FinishOn)}</span></dd>
            {{/if}}
        </dl>
        <dl class="workitemList-dl">
            <dt class="workitemList-dd-l">
            {{if (Status != "Completed")}}
                <span>预计工时: </span>
            {{else}}
                <span>所用工时: </span>
            {{/if}}
            </dt>
            <dd class="workitemList-dd-r">
                <input type="text" class="workitemList-Points" name="points" value="${Points}">
            </dd>
        </dl>
        <dl class="workitemList-dl">
            <dt class="workitemList-container-description workitemList-dd-l"><span>描述:</span>
            </dt>
            <dd class="workitemList-dd-r">
                <input type="text" class="workitemList-description" name="description" value="${Description}">
            </dd>
        </dl>
        <dl class="workitemList-dl  workitem-projcet-dl" style="display: none;">
            <dt class="workitemList-dd-l">关联项目: </dt>
            <dd class="workitemList-dd-r">
                <select class="workitemList-project-selcetor">
                </select>
                <input class="workitemList-hidden-projectId" type="hidden" name="projectId">
            </dd>
        </dl>
        <dl class="workitemList-dl  workitem-task-dl" style="display: none;">
            <dt class="workitemList-dd-l">计划: </dt>
            <dd class="workitemList-dd-r">
                <select class="workitemList-task-selcetor">
                </select>
                <input class="workitemList-hidden-taskId" type="hidden" name="taskId">
            </dd>
        </dl>
        <dl class="workitemList-dl workitemList-isTrace-dl">
            <dt><input type="checkbox" name="isTrace" value="true" checked="checked" class="workitemList-isTrace" id="ckb-trace-${Id}" /><label for="ckb-trace-${Id}" class="lbl-for-ckb">追踪这个任务</label></dt>
        </dl>
    </div>
    <div class="workitemList-container-btn">
        <span class="btn-submit button blue">完成</span>
        &nbsp;或者&nbsp;<a class="btnCancel">取消修改</a></div>
    </form>
</script>


<script>
    var TitleClass = {
        4: "qtip-workitem-ready",
        3: "qtip-workitem-unconfirmed",
        2: "qtip-workitem-expired",
        1: "qtip-workitem-finished",
        0: "qtip-workitem-ongoing"
    };

    var StatusDom = {
        4: "未指定负责人",
        3: "等待 ${OwnerName} 确认",
        2: "任务负责人: ${OwnerName} ",
        1: "${OwnerName} 于 ${GetNiceTime(FinishOn)} 完成了这个任务",
        0: "任务负责人: ${OwnerName} "
    };
    
</script>
<script id="workitemQTip" type="text/x-jquery-tmpl">
<div>
    <div class="qtip-workitem-title ${TitleClass[StatusValue]}">
        <span>${Title}</span></div>
    <div class="qtip-workitem-info">
        <p>
           {{if (Status == "Completed")}}
                <strong>${OwnerName}</strong>&nbsp;于&nbsp;${GetNiceTime(FinishOn)}&nbsp;完成了这个任务
            {{else (Status == "Ready")}}
                还未指定负责人
            {{else (Status == "WaitingForConfirm")}}
                <strong>${OwnerName}</strong>&nbsp; 还没有确认这个任务
            {{else (Status == "Ongoing")}}
                任务负责人:&nbsp;<strong>${OwnerName}</strong>
            {{else (Status == "Expired")}}
                任务负责人:&nbsp;<strong>${OwnerName}</strong>
            {{/if}}
        </p>
        <p>
            这个任务由<strong> ${CreatorName} </strong>创建于 ${GetNiceTime(CreateOn)} <span class="qtip-workitem-points">
            ${Points} 工时</p>
    </div>
    {{if Description }}
    <div>
        <p class="qtip-workitem-title qtip-workitem-description">
            描述</p>
        <p class="qtip-workitem-info">
            ${Description}</p>
    </div>
    {{/if}}
    {{if Project}}
        <div>
            <p class="qtip-workitem-title qtip-workitem-project">
                关联项目</p>
             {{if Task}}
                <p class="qtip-workitem-info">${Task.Name} &nbsp;--&nbsp; ${Project.Name}</p>
             {{else}}
                <p class="qtip-workitem-info">${Project.Name}</p>
             {{/if}}
        </div>
    {{/if}}
    {{if IsTrace}}
    <div class="qtip-workitem-title qtip-workitem-trace">
        <a class="ui-icon ui-icon-flag workitem-istrace"></a>${CreatorName} 正在追踪这个任务</div>
    {{/if}}
</div>
</script>

<script id="completeWorkitemPanel" type="text/x-jquery-tmpl">
<div class="menu-finishWorkitem"> 
    <div style="margin: 5px 10px; line-height: 1.8em;"> 
        <p class="finish-tips">
            {{if IsMine}}
                即将完成这项任务
            {{else}}
                即将完成 &nbsp; <font style='color:#333'> ${OwnerName}</font> &nbsp;  负责的任务
            {{/if}}
        </p> 
        <div> 
            <p>输入完成任务所用工时：</p> 
            <input class="txtHours text" style="width: 100px;"  value="${Points}"/> 
            <span class="btnFinish" style="margin-left: 5px;" >完成</span> 
        </div> 
    </div> 
</div>
</script>



<script id="extendWorkitemPanel" type="text/x-jquery-tmpl">
<div class="menu-extendWorkitem"> 
    <div style="margin: 5px 10px; line-height: 1.8em;"> 
         <div> 
            <p>延期到：</p> 
            <input class="txtNewPlanOn" style="width: 120px;"}"/> 
            <span class="btnExtend" style="margin-left: 5px;" >确定</span> 
        </div> 
    </div> 
</div>
</script>
